package com.zenithsun.common.security.encrypt;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.*;


import java.io.IOException;

/**
 * 加密
 * @author Jiang
 */
public class EncryptTag extends SimpleTagSupport {

    /**
     * 生成CSRF token Tag
     * @throws JspException
     * @throws IOException
     */
    @Override
    public void doTag() throws JspException, IOException {
        PageContext ctx = (PageContext) getJspContext();
        JspWriter out = ctx.getOut();
        //DES 加密
        String first = "<input type=\"hidden\" id=\"__first_key\" value=\""+EncryptKeys.firstKey+"\"/>";
        String second = "<input type=\"hidden\" id=\"__second_key\" value=\""+EncryptKeys.secondKey+"\"/>";
        String third = "<input type=\"hidden\" id=\"__third_key\" value=\""+EncryptKeys.thirdKey+"\"/>";
        String keys = "<div style=\"display:none;\">"+first+second+third+"</div>";
        out.print(keys);
    }
    
   
}
